

const getUrlParam = function (url, key) {
  const urlSplit = url.split('?')
  const arr = urlSplit[1] ? urlSplit[1].split('&') : []
  const params = {}
  for (let i = 0; i < arr.length; i++) {
    const data = arr[i].split('=')
    if (data.length === 2) {
      params[data[0]] = data[1]
    }
  }
  return params[key]
}



const urlLang = getUrlParam(window.location.href, 'lang')
let language
if(urlLang){
  localStorage.setItem("language", urlLang)
  language = urlLang
}else{
  language = localStorage.getItem("language") || 'zh'
}

export default language
